<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

    <title>全选和取消去选</title>

    <script type="text/javascript">
        $(function () {
            //全选单击事件
            $("#selectAll").click(function () {
                $("[name='cb']").prop("checked",$("#selectAll").prop("checked"));
            });

        });

    </script>

</head>

<body>
<table border="2" solid="black" width="400px" >
    <tr>
        <td><input type="checkbox" id="selectAll">全选/取消全选</td>
        <td name="cb"> </td>
        <td>姓名</td>
        <td>年龄</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/> </td>
        <td>1</td>
        <td>张三</td>
        <td>20</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/> </td>
        <td>2</td>
        <td>李四</td>
        <td>20</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/> </td>
        <td>3</td>
        <td>王五</td>
        <td>20</td>
    </tr>
    <tr>

        <td><input type="checkbox" name="cb"/> </td>
        <td>4</td>
        <td>赵六</td>
        <td>20</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/> </td>
        <td>5</td>
        <td>青龙</td>
        <td>20</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/> </td>
        <td>6</td>
        <td>白虎</td>
        <td>20</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="cb"/> </td>
        <td>7</td>
        <td>朱雀</td>
        <td>20</td>
    </tr>
</table>
</body>
</html>